Skip to content

Add a PostgreSQL client with password, NTLM and Kerberos authentication - #2397

Open
azoxlpf wants to merge 3 commits into
fortra:masterfrom
azoxlpf:feat/add-postgresql-client
Open

azoxlpf wants to merge 3 commits into
fortra:masterfrom
azoxlpf:feat/add-postgresql-client

Conversation

@azoxlpf

@azoxlpf azoxlpf commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds a PostgreSQL client to impacket: a new impacket/postgresql.py module implementing the frontend/backend protocol 3.0, and a pgsqlclient.py example on top of it.

Supported:

  • Local accounts: cleartext, md5 and SCRAM-SHA-256 (with tls-server-end-point channel binding over TLS)
  • NTLM (sspi), with password or NT hash
  • Kerberos (gss and sspi), with password, NT hash, AES key or ccache, with mutual authentication
  • TLS (negotiated or direct) and GSSAPI session encryption (AES128, AES256, RC4)
  • Simple and extended (parameterized) queries, query cancellation

The server decides which method is used, so PostgreSQL.requestedAuth exposes what it asked for and PostgreSQL.authMethod what actually authenticated the session (trust means nothing was verified). login(..., allowedMethods=('sspi',)) / -windows-auth refuses to send a domain password to a server asking for a password method.

Tested against PostgreSQL 17 on Windows Server 2016 (sspi) and PostgreSQL 13/16/17 on Linux (gss), with an Active Directory KDC. Offline tests are in tests/misc/test_postgresql.py.

Windows :

  • pg_hba.conf
image
  • local auth :
image
  • NTLM auth :
image
  • Kerberos auth :
image
  • Shell :
image

Linux :

  • pg_hba.conf :
image
  • local auth :
image
  • kerberos auth :
image
  • kerberos auth with GSSAPI encryption :
image
  • Shell :
image

@azoxlpf
azoxlpf marked this pull request as ready for review November 29, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Examples medium Medium priority item

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants